#ifndef _FORMATION_H_
#define _FORMATION_H_

#include <string>
#include <boost/property_tree/ptree.hpp>

#include "include/GlobalGameObj.h"

using namespace std;
using namespace boost::property_tree;

#define FORMATION_POS_NUM 9

class Formation
{
public:
	enum FormationType
	{
		TypePlayer,
		TypeMonster,
		TypeTeam,
	};

	struct FormationInfo
	{
		int type;
		int owner_id;
		int first_attack;

		string pos1;
		string pos2;
		string pos3;
		string pos4;
		string pos5;
		string pos6;
		string pos7;
		string pos8;
		string pos9;

		// system related
		string created;
		string updated;
	};

	struct ActorInfo
	{
		int type;
		int id;
		int pos;
	};

	static void GetFormation(GlobalGameObj *p_game_obj, int type, int owner_id, FormationInfo *p_info);
	static void SetFormation(GlobalGameObj *p_game_obj, FormationInfo *p_info);
	static void GetFormationTree(GlobalGameObj *p_game_obj, int type, int owner_id, ptree &info_tree);
	static int GetNextActor(FormationInfo *p_info, ActorInfo *p_actor_info, int start_index);
	static string GetPosStr(FormationInfo *p_info, int index);
	static void PosStr2ActorInfo(string pos_str, ActorInfo *p_actor_info);

private:
    static void GetPlayerFormation(GlobalGameObj *p_game_obj, int character_id, FormationInfo *p_info);
    static void GetMonsterFormation(GlobalGameObj *p_game_obj, int monster_id, FormationInfo *p_info);
    static void GetTeamFormation(GlobalGameObj *p_game_obj, int character_id, FormationInfo *p_info);
    static void FillFormation(vector<string> strList, FormationInfo *p_info);
    static void SetPlayerFormation(GlobalGameObj *p_game_obj, FormationInfo *p_info);
    static void SetMonsterFormation(GlobalGameObj *p_game_obj, FormationInfo *p_info);
    static void SetTeamFormation(GlobalGameObj *p_game_obj, FormationInfo *p_info);
};

#endif
